<?php
header ( 'content-type:text/html; charset=utf-8' );
@$login = $_REQUEST ['login'];
@$password = $_REQUEST ['password'];

if (empty ( $login ) || empty ( $password )) { // 登录名密码都为 空 就提示登录信息不完整
	header ( 'Refresh:2;url=/t4.php' );
	die ( '<h3>登录信息不完整</h3><a href="/t4.php">返回重新登录</a>' );
}

$pdo = new PDO ( 'mysql:dbname=no;charset=utf8', 'root' );

$s = $pdo->prepare ( 'select id,password from cc where login=:login' );
$s->execute ( array (
		'login' => $login 
) );

$cc = $s->fetch ( PDO::FETCH_NAMED );

if (empty ( $cc )) {
	header ( 'Refresh:2;url=/t4.php' );
	die ( '<h3>登录名不存在</h3><a>返回重新登录</a>' );
}
if ($cc ['password'] != $password) {
	header ( 'Refresh:2;url=/t4.php' );
	die ( '<h3>密码错误</h3><a>返回重新登录</a>' );
}

unset ( $cc ['password'] );
$cc ['login'] = $login;

session_start ();
$_SESSION ['cc'] = $cc;

header ( 'Refresh:2;url=/tem5.php' );
die ( '<h3>登录成功</h3><a>访问主页</a>' );